package com.xiaoxin.model.vo;

import com.xiaoxin.model.domain.Announcement;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.text.SimpleDateFormat;

/**
 * @author xiaoxiaode
 * @date 2021-09-10-23:02
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AnnouncementVo {


    private  String id;
    private  String title;
    private  String description;
    private  Integer pages=1;
    private  String createDate;


    public static AnnouncementVo init(Announcement announcement){
        AnnouncementVo vo=new AnnouncementVo();
        BeanUtils.copyProperties(announcement,vo);
        String id= announcement.getId().toString();
        vo.setId(id);
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd hh:mm");
        String created = simpleDateFormat.format(announcement.getCreated());
        vo.setCreateDate(created);
        return  vo;
    }
}
